//@author A0083782W
//singleton protocal

//This class is used to store all previous user input
//so the user can use up and down arrow to loop through
//all the passed inputs
//The limit of amout of info can be stored is in MAX_RECORD
//Every time the user put an enter, push the string inside
//put the cursor to tail
//Use getCurrentString() to display the result


#pragma once
#include <string>
#include <vector>
#include "CommonDataType.h"
#include "UserCommandEnum.h"
#include "TECommonFunctions.h"

using namespace CommonDataType;
using std::string;
static ByteInt MAX_RECORD = 30;
using StringManipulator::NULL_STRING;

struct STRING_LIST_NODE {
	string userInput;
	STRING_LIST_NODE *prev;
	STRING_LIST_NODE *next;
	NodeType myType;
};

class HistoryRecord{
private:
	HistoryRecord();
	HistoryRecord (const HistoryRecord& newHistoryRecord);
	void operator= (const HistoryRecord& rightOperand);
	STRING_LIST_NODE* _head;
	STRING_LIST_NODE* _tail;
	STRING_LIST_NODE* _current;
	pos_int _size;

public:
	pos_int size() const;
	void push_back (con_str& userInput);
	void moveToTail();
	string getCurrentString() const;
	bool moveFront();
	bool moveBack();
	void reset();
	~HistoryRecord();
	static HistoryRecord& get();
};
